Core.Test.registerTest({
	group: "dao",
	name: "Core.Storage.Trace",
	
	before: function() {
		this.trace = new Core.Storage.Trace(Res.Storage.ListenerA);
		this.local = new Core.Storage.Observable();
	},
	
	"Should register to all paths tracked (global)": function() {
		this.trace.start();
		this.trace.track("user.login", Core.Storage);
		this.trace.track("user.current", Core.Storage);
		this.trace.stop();
		
		Assert.Storage.registered("user.login", Res.Storage.ListenerA);
		Assert.Storage.registered("user.current", Res.Storage.ListenerA);
		Assert.Storage.unregistered("menu", Res.Storage.ListenerA);
	},
	
	"Should register to all paths tracked (local)": function() {
		this.trace.start();
		this.trace.track("login", this.local);
		this.trace.track("password", this.local);
		this.trace.stop();
		
		Assert.Storage.registered("login", Res.Storage.ListenerA, this.local);
		Assert.Storage.registered("password", Res.Storage.ListenerA, this.local);
	},
	
	"Should register to all paths tracked (mixed)": function() {
		this.trace.start();
		this.trace.track("login", this.local);
		this.trace.track("status", this.local);
		this.trace.track("user.login", Core.Storage);
		this.trace.stop();
		
		Assert.Storage.registered("login", Res.Storage.ListenerA, this.local);
		Assert.Storage.registered("status", Res.Storage.ListenerA, this.local);
		
		Assert.Storage.registered("user.login", Res.Storage.ListenerA);
		Assert.Storage.unregistered("user.current", Res.Storage.ListenerA);
	},
	
	"Should re-register if tracked paths change": function() {
		this.trace.start();
		this.trace.track("login", this.local);
		this.trace.track("status", this.local);
		this.trace.track("user.login", Core.Storage);
		this.trace.stop();
		
		this.trace.start();
		this.trace.track("login", this.local);
		this.trace.track("user.current", Core.Storage);
		this.trace.stop();
		
		Assert.Storage.registered("login", Res.Storage.ListenerA, this.local);
		Assert.Storage.unregistered("status", Res.Storage.ListenerA, this.local);
		
		Assert.Storage.registered("user.current", Res.Storage.ListenerA);
		Assert.Storage.unregistered("user.login", Res.Storage.ListenerA);
	},
	
	"Should unregister all on dispose": function() {
		this.trace.start();
		this.trace.track("login", this.local);
		this.trace.track("status", this.local);
		this.trace.track("user.login", Core.Storage);
		this.trace.stop();
		this.trace.dispose();
		
		Assert.Storage.unregistered("login", Res.Storage.ListenerA, this.local);
		Assert.Storage.unregistered("status", Res.Storage.ListenerA, this.local);
		Assert.Storage.unregistered("user.login", Res.Storage.ListenerA);
	}
});